#! /usr/bin/env python
# -*- coding: utf-8 -*-

from playwright.sync_api import Page
from common.base_page import BasePage
from locators.majorHazardSourceSafety.olMonitorWarn.realtimeMonitor.loc_query import LocQuery
from common.logger import logger


class QueryList(BasePage):

    def __init__(self, page: Page):
        super().__init__(page)
        self.switch_menu('重大危险源安全管理')
        self.switch_menu('在线监测预警')
        self.switch_menu('实时监测')

    def query_total_list(self, area_name, device_name, alarm_status, danger_type, danger_level, danger_name):
        logger.info('开始实时监测查询测试')
        logger.info('选择区域名称')
        self.select(LocQuery.loc_area, area_name)
        logger.info('选择设备名称')
        self.select(LocQuery.loc_device_name, device_name)
        logger.info('选择报警状态')
        self.select(LocQuery.loc_alarm_status, alarm_status)
        logger.info('选择重大危险源类型')
        self.select(LocQuery.loc_danger_type, danger_type)
        logger.info('选择重大危险源级别')
        self.select(LocQuery.loc_danger_level, danger_level)
        logger.info('输入重大危险源名称')
        self.fill(LocQuery.loc_danger_name, danger_name)
        self.click(LocQuery.loc_query, exact=True)
